home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-23 | 1.7 KB | 72 lines | [TEXT/MSET] |
- \ Menu class.
- \ Sept 90 mrh item# anomalies fixed
-
- from MENUMOD import{ MENU APPLEMENU EDITMENU }
-
- compile: menuMod
- lock: menuMod
- true setInstall: MenuMod
-
-
- : DODSK \ ( item# -- item# ) Executes the desk accessory for an item.
- \ Note we can send a late-bound msg to self even though we're
- \ not lexically in a class, since this word will only be called
- \ from a method.
-
- dup openDesk: [self] ;
-
-
- : MSELECT \ ( point -- item# menuID ) Calls menu manager to track a menu selection
- 0 swap call MenuSelect unpack swap 1- swap ;
-
-
- :class MBAR super{ object }
-
- 24 ordered-col IDs
- 24 array MENUS \ array of menu objects
-
- :m DRAW: call DrawMenuBar ;m
-
- :m CLEAR: call ClearMenuBar clear: IDs ;m
-
- :m ADD: \ ( men1 ... menN N -- ) Adds menu objects to the MenuBar object.
-
- 0 DO i to: menus i at: menus id: ** add: ids LOOP ;m
-
- :m NEW: \ Inserts menus in Toolbox MenuBar list.
- size: IDs 0
- do size: IDs 1- i - at: menus insert: ** loop
- draw: self ;m
-
- :m INIT: \ ( men1 ... menN N -- )
- clear: self add: self new: self ;m
-
- :m EXEC: \ ( item# MenuID -- )
- dup 0>
- IF indexOf: IDs IF at: menus exec: ** THEN
- ELSE 2drop
- THEN ;m
-
- :m CLICK: where: fevent mSelect exec: self ;m
-
- :m KEY: \ ( c -- ) Handles a possible menu key selection
- 0 swap makeint call MenuKey unpack swap 1- swap
- exec: self ;m
-
- :m ENABLE: \ Enables all menus in the Menu Bar
- size: IDs 0
- DO i at: menus handle: ** word0 call EnableItem LOOP
- draw: self ;m
-
- :m DISABLE:
- size: IDs 0
- DO i at: menus handle: ** word0 call DisableItem LOOP
- draw: self ;m
-
- ;class
-
-
- mBar MENUBAR \ Our default menu bar
-
- menubar put: MBaddr \ Set as current menu bar
-